﻿namespace com.stifel.ServerBuildMgmt
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    using com.stifel.Extensions.ObjectExtensions;
    using com.stifel.Extensions.StringExtensions;
    using com.stifel.ServerBuildMgmtDao;

    public class Summary
    {
        #region Fields

        const string ADLit1 = "View 1 : ";
        const string ADLit2 = "View 2 : ";
        const string ADNotes = "Notes : ";
        const string AntiVirusLit1 = "View 1 : ";
        const string AntiVirusLit2 = "View 2 : ";
        const string AntiVirusNotes = "Notes : ";
        const string AvPolicy = "Policy : ";
        const string BackupAgents = "Agents : ";
        const string BackUpLit1 = "View 1 : ";
        const string BackUpLit2 = "View 2 : ";
        const string BackUpNotes = "Notes : ";
        const string BackupPolicy = "Policy : ";
        const string BackupRetentionTime = "Retention Time : ";
        const string BuildLit1 = "View 1 : ";
        const string BuildLit2 = "View 2 : ";
        const string BuildNotes = "Notes : ";
        const string Cpu = "CPUs : ";
        const string DayHours = "Day Hours : ";
        const string DisasterRecoveryReplicationType = "Replication Type : ";
        const string DisasterRecoveryReplicationTypeOther = "Description : ";
        const string DisasterRecoveryRequested = "Requested ? ";
        const string InstallUpdates = "Ok to install all of Windows Updates and Service Packs ? ";
        const string isAdCompleted = "Is AD Completed : ";
        const string isAvCompleted = "Is Antivirus Completed : ";
        const string isBackupCompleted = "Is Backup Completed : ";
        const string isBuildCompleted = "Is Build Completed : ";
        const string isMnCompleted = "Is Network Completed : ";
        const string isPatchCompleted = "Is Patch Completed : ";
        const string Location = "Location : ";
        const string Memory = "Memory(GB) : ";
        const string MoniteringNetworkLit1 = "View 1 : ";
        const string MoniteringNetworkLit2 = "View 2 : ";
        const string MoniteringNetworkNotes = "Notes : ";
        const string NameExistingServer = "Name of existing server : ";
        const string NetworkConnectionNumber = "Number : ";
        const string NetworkConnectionOther = "Description : ";
        const string NetworkConnectionType = "Type : ";
        const string NightHours = "Night Hours : ";
        const string NO = "NO";
        const string Notes = "Notes : ";
        const string OperatingSystem = "Operating System : ";
        const string PatchLit1 = "View 1 : ";
        const string PatchLit2 = "View 2 : ";
        const string PatchNotes = "Notes : ";
        const string ReplaceExisting = "Is this server replacing an existing server ? ";
        const string ServerDescription = "Description : ";
        const string ServerName = "Server Name : ";
        const string Vlan = "VLAN : ";
        const string VlanCluster = "VLAN Clusters : ";
        const string YES = "YES";
        const string Reason = "Reason : ";
        const string Virtual = "Virtual";
        const string Agent = "Agent";

        #endregion Fields

        #region Properties

        int summaryRow
        {
            get;
            set;
        }

        #endregion Properties

        #region Methods

        public List<RepeaterBinding> getSummary( VirtualServerCollectionClass v )
        {
            List<RepeaterBinding> ret = new List<RepeaterBinding>( );
            RepeaterBinding newRepeaterBinding;
            List<ServerValues> vals = v.virtualServerCollection;
            foreach ( ServerValues server in vals )
            {
                newRepeaterBinding = new RepeaterBinding( );
                newRepeaterBinding.summary = setTotalSummary( setSummary( server.ServerBasics, server.OriginalRequest ) + setSummary( server.HardDrives, server.DefaultHardDriveName, server.DefaultHardDriveSize, server.DefaultHardDrive, server.OriginalRequest ) + setSummary( server.NetworkConnections, server.OriginalRequest ) + setSummary( server.DisasterRecovery, server.OriginalRequest ) + setSummary( server.ServerRolesAndSubRoles, server.OriginalRequest ) + setSummary( server.Access, server.OriginalRequest ) + setSummary( server.BackupSchedule, server.OriginalRequest ) + setSummary( server.Notes, server.OriginalRequest ) + setSummary( server.Backup ) + setSummary( server.AD ) + setSummary( server.AntiVirus ) + setSummary( server.MoniteringNetwork ) + setSummary( server.Patch ) + setSummary( server.Build ) );
                newRepeaterBinding.value = server.SerializeToXml<ServerValues>( ).ToBase64String( );
                ret.Add( newRepeaterBinding );
            }

            return ( ret );
        }

        //public string getSummary( ServerValues server )
        //{
        //    return ( setTotalSummary( setSummary( server.ServerBasics, server.OriginalRequest ) + setSummary( server.HardDrives, server.DefaultHardDriveName, server.DefaultHardDriveSize, server.DefaultHardDrive, server.OriginalRequest ) + setSummary( server.NetworkConnections, server.OriginalRequest ) + setSummary( server.DisasterRecovery, server.OriginalRequest ) + setSummary( server.ServerRoles, server.OriginalRequest ) + setSummary( server.Access, server.OriginalRequest ) + setSummary(server.BackupSchedule,server.OriginalRequest) +setSummary( server.Notes, server.OriginalRequest ) + setSummary( server.Backup ) + setSummary( server.AD ) + setSummary( server.AntiVirus ) + setSummary( server.MoniteringNetwork ) + setSummary( server.Patch ) + setSummary( server.Build ) ) );
        //}
        public List<RepeaterBinding> getSummaryWithOutOriginalValues( VirtualServerCollectionClass v )
        {
            List<RepeaterBinding> ret = new List<RepeaterBinding>( );
            RepeaterBinding newRepeaterBinding;
            List<ServerValues> vals = v.virtualServerCollection;
            foreach ( ServerValues server in vals )
            {
                newRepeaterBinding = new RepeaterBinding( );
                newRepeaterBinding.summary = setTotalSummary( setSummary( server.ServerBasics ) + setSummary( server.HardDrives, server.DefaultHardDriveName, server.DefaultHardDriveSize, server.DefaultHardDrive ) + setSummary( server.NetworkConnections ) + setSummary( server.DisasterRecovery ) + setSummary( server.ServerRolesAndSubRoles ) + setSummary( server.Access ) + setSummary( server.BackupSchedule ) + setSummary( server.Notes ) + setSummary( server.Backup ) + setSummary( server.AD ) + setSummary( server.AntiVirus ) + setSummary( server.MoniteringNetwork ) + setSummary( server.Patch ) + setSummary( server.Build ) );
                newRepeaterBinding.value = server.SerializeToXml<ServerValues>( ).ToBase64String( );
                ret.Add( newRepeaterBinding );
            }

            return ( ret );
        }

        public string getSummaryWithOutOriginalValues( ServerValues server )
        {
            return ( setTotalSummary( setSummary( server.ServerBasics ) + setSummary( server.HardDrives, server.DefaultHardDriveName, server.DefaultHardDriveSize, server.DefaultHardDrive ) + setSummary( server.NetworkConnections ) + setSummary( server.DisasterRecovery ) + setSummary( server.ServerRolesAndSubRoles ) + setSummary( server.Access ) + setSummary( server.BackupSchedule ) + setSummary( server.Notes ) + setSummary( server.Backup ) + setSummary( server.AD ) + setSummary( server.AntiVirus ) + setSummary( server.MoniteringNetwork ) + setSummary( server.Patch ) + setSummary( server.Build ) ) );
        }

        TableRow buildSummary( string value )
        {
            TableRow r = new TableRow( );
            TableCell c = new TableCell( );
            c.Style.Add( HtmlTextWriterStyle.TextAlign, TextAlign.Left );
            c.CssClass = CssClass.Data;
            c.Controls.Add( new Literal
            {
                Text = value
            } );
            r.Cells.Add( c );

            r.CssClass = tableclass( );
            return r;
        }

        string panelsToHtmlString( Panel p )
        {
            //Converting the comman panel to HTML string.
            StringWriter s = new StringWriter( );
            p.RenderControl( new HtmlTextWriter( s ) );
            return ( s.ToString( ) );
        }

        string setSummary( ServerBasics sb )
        {
            Panel p = new Panel
            {
                GroupingText = "Basics"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            t.Rows.Add( buildSummary( ServerName + sb.ServerName ) );
            t.Rows.Add( buildSummary( ServerDescription + sb.ServerDescription ) );
            t.Rows.Add( buildSummary( OperatingSystem + sb.OperatingSystem ) );
            if ( ( sb.Reason != null ) && ( sb.Reason != string.Empty ) )
            {
                t.Rows.Add( buildSummary( Reason + sb.Reason ) );
            }
            t.Rows.Add( buildSummary( Memory + sb.MemoryList.ToString( ) ) );
            t.Rows.Add( buildSummary( Cpu + sb.CPUs.ToString( ) ) );
            if ( sb.LocationCity == string.Empty )
            {
                t.Rows.Add( buildSummary( Location + string.Empty ) );
            }
            else
            {
                t.Rows.Add( buildSummary( Location + sb.LocationCity + "," + sb.LocationStateAbbrivation + " (" + sb.LocationTimeZoneId + ")" ) );
            }
            if ( sb.WindowsUpdate == true )
            {
                t.Rows.Add( buildSummary( InstallUpdates + YES ) );
            }
            else
            {
                t.Rows.Add( buildSummary( InstallUpdates + NO ) );
            }
            if ( sb.ReplaceServer == true )
            {
                t.Rows.Add( buildSummary( ReplaceExisting + YES ) );
                t.Rows.Add( buildSummary( NameExistingServer + sb.ExistingServerName ) );
            }
            else
            {
                t.Rows.Add( buildSummary( ReplaceExisting + NO ) );
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( List<HardDrives> hd, string dftHardDriveName, string dftHardDriveSize, string dftHardDrive )
        {
            Panel p = new Panel
            {
                GroupingText = "Hard Drives"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            t.Rows.Add( buildSummary( dftHardDrive + " " + dftHardDriveName + " : " + dftHardDriveSize ) );
            foreach ( HardDrives h in hd )
            {
                if ( h.Name == string.Empty )
                {
                }
                else
                {
                    t.Rows.Add( buildSummary( h.Drive + " " + h.Name + " : " + h.Size.ToString( ) + "GB" + " {" + h.Type + "}" ) );
                }
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( NetworkConnection n )
        {
            Panel p = new Panel
            {
                GroupingText = "Network Connection"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            t.Rows.Add( buildSummary( NetworkConnectionType + n.Type ) );
            if ( ( n.OtherDescription != string.Empty ) && ( n.OtherDescription != null ) )
            {
                t.Rows.Add( buildSummary( NetworkConnectionNumber + n.OtherDescription ) );
            }
            if ( ( n.ClusterVlan != string.Empty ) && ( n.ClusterVlan != null ) )
            {
                t.Rows.Add( buildSummary( VlanCluster + n.ClusterVlan ) );
            }
            if ( ( n.VlanInfo != string.Empty ) && ( n.VlanInfo != null ) )
            {
                t.Rows.Add( buildSummary( Vlan + n.VlanInfo ) );
            }
            if ( n.Number > 1 )
            {
                t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) ) );
                t.Rows.Add( buildSummary( Reason + n.Reason ) );
            }
            else
            {
                t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) ) );
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( DisasterRecovery dr )
        {
            Panel p = new Panel
            {
                GroupingText = "Disaster Recovery"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( dr.Requested == true )
            {
                t.Rows.Add( buildSummary( DisasterRecoveryRequested + YES ) );
                t.Rows.Add( buildSummary( DisasterRecoveryReplicationType + dr.ReplicationType ) );
                if ( ( dr.Other != string.Empty ) && ( dr.Other != null ) )
                {
                    t.Rows.Add( buildSummary( DisasterRecoveryReplicationTypeOther + dr.Other ) );
                }
            }
            else
            {
                t.Rows.Add( buildSummary( DisasterRecoveryRequested + NO ) );
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( List<ServerRolesAndSubRoles> srasb )
        {
            Panel p = new Panel
            {
                GroupingText = "Server Roles"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            foreach ( ServerRolesAndSubRoles s in srasb )
            {
                if ( ( s.SubRoles != null ) && ( s.SubRoles.Count != 0 ) )
                {
                    t.Rows.Add( buildSummary( s.ServerRole ) );
                    foreach ( string str in s.SubRoles )
                    {
                        t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + str ) );
                    }
                }
                else
                {
                    t.Rows.Add( buildSummary( s.ServerRole ) );
                }
            }
            //foreach ( string s in sr.ServerRole )
            //{
            //    t.Rows.Add( buildSummary( s ) );
            //    foreach ( ServerRolesAndSubRoles Sbr in sr.ServerSubRoles )
            //    {
            //        if ( s == Sbr.ServerRole )
            //        {
            //            foreach ( string SbrString in Sbr.SubRoles )
            //            {
            //                t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + SbrString ) );
            //            }
            //        }
            //    }
            //}
            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        //string setSummary( ServerRoles sr )
        //{
        //    Panel p = new Panel
        //    {
        //        GroupingText = "Server Roles"
        //    };
        //    Table t = new Table( );
        //    t.Width = new Unit( 100, UnitType.Percentage );
        //    foreach ( string s in sr.ServerRole )
        //    {
        //        t.Rows.Add( buildSummary( s ) );
        //        foreach ( ServerRolesAndSubRoles Sbr in sr.ServerSubRoles )
        //        {
        //            if ( s == Sbr.ServerRole )
        //            {
        //                foreach ( string SbrString in Sbr.SubRoles )
        //                {
        //                    t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + SbrString ) );
        //                }
        //            }
        //        }
        //    }
        //    if ( t.Rows.Count == 0 )
        //    {
        //        return ( string.Empty );
        //    }
        //    else
        //    {
        //        p.Controls.Add( t );
        //        return ( panelsToHtmlString( p ) );
        //    }
        //}
        string setSummary( List<Access> a )
        {
            Panel p = new Panel
            {
                GroupingText = "Access"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            foreach ( Access ac in a )
            {
                if ( ( ac.User != null ) && ( ac.Role != null ) )
                {
                    if ( ( ac.User != string.Empty ) && ( ac.Role != string.Empty ) )
                    {
                        t.Rows.Add( buildSummary( ac.User + " : " + ac.Role ) );
                    }
                }
            }
            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( BackupSchedule bs )
        {
            Panel p = new Panel
            {
                GroupingText = "Backup Schedule"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            string s1 = string.Empty;
            foreach ( BackUpScheduleType busType in bs.BusType )
            {
                if ( ( busType.Virtual.HasValue ) && ( !busType.Agent.HasValue ) )
                {
                    s1 = string.Concat( s1, busType.Virtual.Value.ToString( ) + ", " + Virtual + ", " + busType.Type, ";" );
                }
                if ( ( busType.Agent.HasValue ) && ( !busType.Virtual.HasValue ) )
                {
                    s1 = string.Concat( s1, busType.Agent.Value.ToString( ) + ", " + Agent + ", " + busType.Type, ";" );
                }
                if ( ( busType.Virtual.HasValue ) && ( busType.Agent.HasValue ) )
                {
                    if ( busType.Virtual.Value == busType.Agent.Value )
                    {
                        s1 = string.Concat( s1, busType.Agent.Value.ToString( ) + ", " + Virtual + ", " + Agent + ", " + busType.Type, ";" );
                    }
                }
            }
            if ( ( s1 != string.Empty ) && ( s1 != null ) )
            {
                string str = s1.Substring( 0, s1.Length - 1 );
                t.Rows.Add( buildSummary( bs.BackupHours + " : " + str ) );
            }
            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( BackupSchedule bs, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Backup Schedule"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                string s1 = string.Empty;
                foreach ( BackUpScheduleType busType in bs.BusType )
                {
                    if ( ( busType.Virtual.HasValue ) && ( !busType.Agent.HasValue ) )
                    {
                        s1 = string.Concat( s1, busType.Virtual.Value.ToString( ) + ", " + Virtual + ", " + busType.Type, ";" );
                    }
                    if ( ( busType.Agent.HasValue ) && ( !busType.Virtual.HasValue ) )
                    {
                        s1 = string.Concat( s1, busType.Agent.Value.ToString( ) + ", " + Agent + ", " + busType.Type, ";" );
                    }
                    if ( ( busType.Virtual.HasValue ) && ( busType.Agent.HasValue ) )
                    {
                        if ( busType.Virtual.Value == busType.Agent.Value )
                        {
                            s1 = string.Concat( s1, busType.Agent.Value.ToString( ) + ", " + Virtual + ", " + Agent + ", " + busType.Type, ";" );
                        }
                    }
                }
                if ( ( s1 != string.Empty ) && ( s1 != null ) )
                {
                    string str = s1.Substring( 0, s1.Length - 1 );
                    t.Rows.Add( buildSummary( bs.BackupHours + " : " + str ) );
                }
            }
            else
            {
                string s1 = string.Empty;
                if ( ( bs.BackupHours.Trim( ) != string.Empty ) && ( bs.BackupHours.Trim( ) != null ) )
                {
                    s1 = bs.BackupHours.Trim( ) + " : ";
                }
                string strs1 = string.Empty;
                string strs2 = string.Empty;
                string originals1 = string.Empty;
                if ( ( or.BackupSchedule.BackupHours.Trim( ) != string.Empty ) && ( or.BackupSchedule.BackupHours.Trim( ) != null ) )
                {
                    originals1 = or.BackupSchedule.BackupHours.Trim( ) + " : ";
                }
                string stroriginals1 = string.Empty;
                foreach ( BackUpScheduleType busType in bs.BusType )
                {
                    if ( ( busType.Virtual.HasValue ) && ( !busType.Agent.HasValue ) )
                    {
                        s1 = string.Concat( s1, busType.Virtual.Value.ToString( ) + ", " + Virtual + ", " + busType.Type, ";" );
                    }
                    if ( ( busType.Agent.HasValue ) && ( !busType.Virtual.HasValue ) )
                    {
                        s1 = string.Concat( s1, busType.Agent.Value.ToString( ) + ", " + Agent + ", " + busType.Type, ";" );
                    }
                    if ( ( busType.Virtual.HasValue ) && ( busType.Agent.HasValue ) )
                    {
                        if ( busType.Virtual.Value == busType.Agent.Value )
                        {
                            s1 = string.Concat( s1, busType.Agent.Value.ToString( ) + ", " + Virtual + ", " + Agent + ", " + busType.Type, ";" );
                        }
                    }
                }
                if ( ( s1 != string.Empty ) && ( s1 != null ) )
                {
                    strs1 = s1.Substring( 0, s1.Length - 1 );
                }
                foreach ( BackUpScheduleType obusType in or.BackupSchedule.BusType )
                {
                    //originals1 = string.Concat( originals1, odh.ToString( ), "," );
                    if ( ( obusType.Virtual.HasValue ) && ( !obusType.Agent.HasValue ) )
                    {
                        originals1 = string.Concat( originals1, obusType.Virtual.Value.ToString( ) + ", " + Virtual + ", " + obusType.Type, ";" );
                    }
                    if ( ( obusType.Agent.HasValue ) && ( !obusType.Virtual.HasValue ) )
                    {
                        originals1 = string.Concat( originals1, obusType.Agent.Value.ToString( ) + ", " + Agent + ", " + obusType.Type, ";" );
                    }
                    if ( ( obusType.Virtual.HasValue ) && ( obusType.Agent.HasValue ) )
                    {
                        if ( obusType.Virtual.Value == obusType.Agent.Value )
                        {
                            originals1 = string.Concat( originals1, obusType.Agent.Value.ToString( ) + ", " + Virtual + ", " + Agent + ", " + obusType.Type, ";" );
                        }
                    }
                }
                if ( ( originals1 != string.Empty ) && ( originals1 != null ) )
                {
                    stroriginals1 = originals1.Substring( 0, originals1.Length - 1 );
                }

                if ( ( strs1.Equals( stroriginals1, StringComparison.InvariantCultureIgnoreCase ) ) && ( strs1 != string.Empty ) )
                {
                    t.Rows.Add( buildSummary( strs1 ) );
                }
                else if ( ( !( strs1.Equals( stroriginals1, StringComparison.InvariantCultureIgnoreCase ) ) ) && ( strs1 == string.Empty ) )
                {
                    t.Rows.Add( buildSummary( " [" + stroriginals1 + "]" ) );
                }
                else if ( ( !( strs1.Equals( stroriginals1, StringComparison.InvariantCultureIgnoreCase ) ) ) && ( stroriginals1 == string.Empty ) )
                {
                    t.Rows.Add( buildSummary( strs1 ) );
                }
                else if ( ( !( strs1.Equals( stroriginals1, StringComparison.InvariantCultureIgnoreCase ) ) ) && ( stroriginals1 != string.Empty ) && ( strs1 != string.Empty ) )
                {
                    t.Rows.Add( buildSummary( strs1 + " [" + stroriginals1 + "]" ) );
                }
                else
                {
                }
            }
            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( Notes n )
        {
            Panel p = new Panel
            {
                GroupingText = "Notes"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( ( n.Note != null ) && ( n.Note != string.Empty ) )
            {
                t.Rows.Add( buildSummary( Notes + n.Note ) );
            }
            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( ServerBasics sb, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Basics"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                t.Rows.Add( buildSummary( ServerName + sb.ServerName ) );
                t.Rows.Add( buildSummary( ServerDescription + sb.ServerDescription ) );
                t.Rows.Add( buildSummary( OperatingSystem + sb.OperatingSystem ) );
                if ( ( sb.Reason != null ) && ( sb.Reason != string.Empty ) )
                {
                    t.Rows.Add( buildSummary( Reason + sb.Reason ) );
                }
                t.Rows.Add( buildSummary( Memory + sb.MemoryList.ToString( ) ) );
                t.Rows.Add( buildSummary( Cpu + sb.CPUs.ToString( ) ) );
                if ( sb.LocationCity == string.Empty )
                {
                    t.Rows.Add( buildSummary( Location + string.Empty ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( Location + sb.LocationCity + "," + sb.LocationStateAbbrivation + " (" + sb.LocationTimeZoneId + ")" ) );
                }
                if ( sb.WindowsUpdate == true )
                {
                    t.Rows.Add( buildSummary( InstallUpdates + YES ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( InstallUpdates + NO ) );
                }
                if ( sb.ReplaceServer == true )
                {
                    t.Rows.Add( buildSummary( ReplaceExisting + YES ) );
                    t.Rows.Add( buildSummary( NameExistingServer + sb.ExistingServerName ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( ReplaceExisting + NO ) );
                }
            }
            else
            {
                if ( sb.ServerName.Equals( or.ServerBasics.ServerName, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    t.Rows.Add( buildSummary( ServerName + sb.ServerName ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( ServerName + sb.ServerName + " [" + ServerName + or.ServerBasics.ServerName + "]" ) );
                }
                if ( sb.ServerDescription.Equals( or.ServerBasics.ServerDescription, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    t.Rows.Add( buildSummary( ServerDescription + sb.ServerDescription ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( ServerDescription + sb.ServerDescription + " [" + ServerDescription + or.ServerBasics.ServerDescription + "]" ) );
                }
                if ( sb.OperatingSystem.Equals( or.ServerBasics.OperatingSystem, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    t.Rows.Add( buildSummary( OperatingSystem + sb.OperatingSystem ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( OperatingSystem + sb.OperatingSystem + " [" + OperatingSystem + or.ServerBasics.OperatingSystem + "]" ) );
                }
                if ( ( sb.Reason != null ) || ( or.ServerBasics.Reason != null ) )
                {
                    if ( ( sb.Reason == null ) && ( or.ServerBasics.Reason != null ) )
                    {
                        if ( or.ServerBasics.Reason != string.Empty )
                        {
                            t.Rows.Add( buildSummary( " [" + Reason + or.ServerBasics.Reason + "]" ) );
                        }
                    }
                    if ( ( sb.Reason != null ) && ( or.ServerBasics.Reason == null ) )
                    {
                        if ( sb.Reason != string.Empty )
                        {
                            t.Rows.Add( buildSummary( Reason + sb.Reason ) );
                        }
                    }
                    if ( ( sb.Reason != null ) && ( or.ServerBasics.Reason != null ) )
                    {
                        if ( sb.Reason.Equals( or.ServerBasics.Reason, StringComparison.InvariantCultureIgnoreCase ) )
                        {
                            t.Rows.Add( buildSummary( Reason + sb.Reason ) );
                        }
                        else
                        {
                            t.Rows.Add( buildSummary( Reason + sb.Reason + " [" + Reason + or.ServerBasics.Reason + "]" ) );
                        }
                    }
                }
                if ( sb.MemoryList == or.ServerBasics.MemoryList )
                {
                    t.Rows.Add( buildSummary( Memory + sb.MemoryList.ToString( ) ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( Memory + sb.MemoryList.ToString( ) + " [" + Memory + or.ServerBasics.MemoryList.ToString( ) + "]" ) );
                }
                if ( sb.CPUs == or.ServerBasics.CPUs )
                {
                    t.Rows.Add( buildSummary( Cpu + sb.CPUs.ToString( ) ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( Cpu + sb.CPUs.ToString( ) + " [" + Cpu + or.ServerBasics.CPUs.ToString( ) + "]" ) );
                }

                if ( sb.LocationItemId == or.ServerBasics.LocationItemId )
                {
                    if ( sb.LocationCity == string.Empty )
                    {
                        t.Rows.Add( buildSummary( Location + string.Empty ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( Location + sb.LocationCity + "," + sb.LocationStateAbbrivation + " (" + sb.LocationTimeZoneId + ")" ) );
                    }
                }
                else
                {
                    if ( sb.LocationCity == string.Empty )
                    {
                        t.Rows.Add( buildSummary( Location + string.Empty + " [" + Location + or.ServerBasics.LocationCity + "," + or.ServerBasics.LocationStateAbbrivation + " (" + or.ServerBasics.LocationTimeZoneId + ")" + "]" ) );
                    }
                    else if ( or.ServerBasics.LocationCity == string.Empty )
                    {
                        t.Rows.Add( buildSummary( Location + sb.LocationCity + "," + sb.LocationStateAbbrivation + " (" + sb.LocationTimeZoneId + ")" + " [" + Location + string.Empty + "]" ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( Location + sb.LocationCity + "," + sb.LocationStateAbbrivation + " (" + sb.LocationTimeZoneId + ")" + " [" + Location + or.ServerBasics.LocationCity + "," + or.ServerBasics.LocationStateAbbrivation + " (" + or.ServerBasics.LocationTimeZoneId + ")" + "]" ) );
                    }
                }

                if ( sb.WindowsUpdate == or.ServerBasics.WindowsUpdate )
                {
                    if ( sb.WindowsUpdate == true )
                    {
                        t.Rows.Add( buildSummary( InstallUpdates + YES ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( InstallUpdates + NO ) );
                    }
                }
                else
                {
                    if ( sb.WindowsUpdate == true )
                    {
                        t.Rows.Add( buildSummary( InstallUpdates + YES + " [" + InstallUpdates + NO + "]" ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( InstallUpdates + NO + " [" + InstallUpdates + YES + "]" ) );
                    }
                }

                if ( sb.ReplaceServer == or.ServerBasics.ReplaceServer )
                {
                    if ( sb.ReplaceServer == true )
                    {
                        t.Rows.Add( buildSummary( ReplaceExisting + YES ) );
                        t.Rows.Add( buildSummary( NameExistingServer + sb.ExistingServerName ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( ReplaceExisting + NO ) );
                    }
                }
                else
                {
                    if ( sb.ReplaceServer == true )
                    {
                        t.Rows.Add( buildSummary( ReplaceExisting + YES + " [" + ReplaceExisting + NO + "]" ) );
                        t.Rows.Add( buildSummary( NameExistingServer + sb.ExistingServerName ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( ReplaceExisting + NO + " [" + ReplaceExisting + YES + "]" ) );
                        t.Rows.Add( buildSummary( " [" + NameExistingServer + or.ServerBasics.ExistingServerName + "]" ) );
                    }
                }
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( List<HardDrives> hd, string dftHardDriveName, string dftHardDriveSize, string dftHardDrive, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Hard Drives"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                t.Rows.Add( buildSummary( dftHardDrive + " " + dftHardDriveName + " : " + dftHardDriveSize ) );
                foreach ( HardDrives h in hd )
                {
                    if ( h.Name == string.Empty )
                    {
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( h.Drive + " " + h.Name + " : " + h.Size.ToString( ) + "GB" + " {" + h.Type + "}" ) );
                    }
                }
            }
            else
            {
                if ( hd.Count != or.HardDrives.Count )
                {
                    t.Rows.Add( buildSummary( dftHardDrive + " " + dftHardDriveName + " : " + dftHardDriveSize ) );
                    foreach ( HardDrives h in hd )
                    {
                        if ( h.Name == string.Empty )
                        {
                        }
                        else
                        {
                            t.Rows.Add( buildSummary( h.Drive + " " + h.Name + " : " + h.Size.ToString( ) + "GB" + " {" + h.Type + "}" ) );
                        }
                    }
                    t.Rows.Add( buildSummary( "[" + or.DefaultHardDrive + " " + or.DefaultHardDriveName + " : " + or.DefaultHardDriveSize + "]" ) );
                    foreach ( HardDrives h in or.HardDrives )
                    {
                        if ( h.Name == string.Empty )
                        {
                        }
                        else
                        {
                            t.Rows.Add( buildSummary( "[" + h.Drive + " " + h.Name + " : " + h.Size.ToString( ) + "GB" + " {" + h.Type + "}" + "]" ) );
                        }
                    }
                }
                else
                {
                    bool CompareEquals = false;
                    bool CompareEqualsInternal = false;
                    string defaultCompare1 = dftHardDrive + " " + dftHardDriveName + " : " + dftHardDriveSize;
                    string defaultCompare2 = or.DefaultHardDrive + " " + or.DefaultHardDriveName + " : " + or.DefaultHardDriveSize;
                    if ( defaultCompare1.Equals( defaultCompare2, StringComparison.InvariantCultureIgnoreCase ) )
                    {

                    }
                    else
                    {
                        CompareEquals = true;
                    }
                    for ( int i = 0; i < hd.Count; i++ )
                    {
                        string cmp1 = hd[ i ].Drive + " " + hd[ i ].Name + " : " + hd[ i ].Size.ToString( ) + "GB" + " {" + hd[ i ].Type + "}";
                        string cmp2 = or.HardDrives[ i ].Drive + " " + or.HardDrives[ i ].Name + " : " + or.HardDrives[ i ].Size.ToString( ) + "GB" + " {" + or.HardDrives[ i ].Type + "}";
                        if ( cmp1.Equals( cmp2, StringComparison.InvariantCultureIgnoreCase ) )
                        {
                        }
                        else
                        {
                            CompareEqualsInternal = true;
                        }
                    }
                    if ( ( CompareEquals == true ) || ( CompareEqualsInternal == true ) )
                    {
                        t.Rows.Add( buildSummary( dftHardDrive + " " + dftHardDriveName + " : " + dftHardDriveSize ) );
                        foreach ( HardDrives h in hd )
                        {
                            if ( h.Name == string.Empty )
                            {
                            }
                            else
                            {
                                t.Rows.Add( buildSummary( h.Drive + " " + h.Name + " : " + h.Size.ToString( ) + "GB" + " {" + h.Type + "}" ) );
                            }
                        }
                        t.Rows.Add( buildSummary( "[" + or.DefaultHardDrive + " " + or.DefaultHardDriveName + " : " + or.DefaultHardDriveSize + "]" ) );
                        foreach ( HardDrives h in or.HardDrives )
                        {
                            if ( h.Name == string.Empty )
                            {
                            }
                            else
                            {
                                if ( h.Size != 0 )
                                    t.Rows.Add( buildSummary( "[" + h.Drive + " " + h.Name + " : " + h.Size.ToString( ) + "GB" + " {" + h.Type + "}" + "]" ) );
                            }
                        }
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( dftHardDrive + " " + dftHardDriveName + " : " + dftHardDriveSize ) );
                        foreach ( HardDrives h in hd )
                        {
                            if ( h.Name == string.Empty )
                            {
                            }
                            else
                            {
                                t.Rows.Add( buildSummary( h.Drive + " " + h.Name + " : " + h.Size.ToString( ) + "GB" + " {" + h.Type + "}" ) );
                            }
                        }
                    }
                }
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( NetworkConnection n, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Network Connection"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                t.Rows.Add( buildSummary( NetworkConnectionType + n.Type ) );
                if ( ( n.OtherDescription != string.Empty ) && ( n.OtherDescription != null ) )
                {
                    t.Rows.Add( buildSummary( NetworkConnectionOther + n.OtherDescription ) );
                }
                if ( ( n.ClusterVlan != string.Empty ) && ( n.ClusterVlan != null ) )
                {
                    t.Rows.Add( buildSummary( VlanCluster + n.ClusterVlan ) );
                }
                if ( ( n.VlanInfo != string.Empty ) && ( n.VlanInfo != null ) )
                {
                    t.Rows.Add( buildSummary( Vlan + n.VlanInfo ) );
                }
                if ( n.Number > 1 )
                {
                    t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) ) );
                    t.Rows.Add( buildSummary( Reason + n.Reason ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) ) );
                }
            }
            else
            {
                if ( n.Type.Equals( or.NetworkConnections.Type, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    t.Rows.Add( buildSummary( NetworkConnectionType + n.Type ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( NetworkConnectionType + n.Type + " [" + NetworkConnectionType + or.NetworkConnections.Type + "]" ) );
                }
                if ( ( n.OtherDescription != string.Empty ) && ( n.OtherDescription != null ) )
                {
                    if ( ( or.NetworkConnections.OtherDescription != string.Empty ) && ( or.NetworkConnections.OtherDescription != null ) )
                    {
                        if ( n.OtherDescription.Equals( or.NetworkConnections.OtherDescription, StringComparison.InvariantCultureIgnoreCase ) )
                        {
                            t.Rows.Add( buildSummary( NetworkConnectionOther + n.OtherDescription ) );
                        }
                        else
                        {
                            t.Rows.Add( buildSummary( NetworkConnectionOther + n.OtherDescription + " [" + NetworkConnectionOther + or.NetworkConnections.OtherDescription + "]" ) );
                        }
                    }
                }
                if ( ( n.OtherDescription == string.Empty ) || ( n.OtherDescription == null ) )
                {
                    if ( ( or.NetworkConnections.OtherDescription != string.Empty ) && ( or.NetworkConnections.OtherDescription != null ) )
                    {
                        t.Rows.Add( buildSummary( "[" + NetworkConnectionOther + or.NetworkConnections.OtherDescription + "]" ) );
                    }
                }
                if ( ( n.OtherDescription != string.Empty ) && ( n.OtherDescription != null ) )
                {
                    if ( ( or.NetworkConnections.OtherDescription == string.Empty ) || ( or.NetworkConnections.OtherDescription == null ) )
                    {
                        t.Rows.Add( buildSummary( NetworkConnectionOther + n.OtherDescription ) );
                    }
                }
                if ( ( n.ClusterVlan != string.Empty ) && ( n.ClusterVlan != null ) )
                {
                    t.Rows.Add( buildSummary( VlanCluster + n.ClusterVlan ) );
                }
                if ( ( n.VlanInfo != string.Empty ) && ( n.VlanInfo != null ) )
                {
                    t.Rows.Add( buildSummary( Vlan + n.VlanInfo ) );
                }
                if ( n.Number == or.NetworkConnections.Number )
                {
                    if ( n.Number > 1 )
                    {
                        t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) ) );
                        if ( n.Reason.Equals( or.NetworkConnections.Reason, StringComparison.InvariantCultureIgnoreCase ) )
                        {
                            t.Rows.Add( buildSummary( Reason + n.Reason ) );
                        }
                        else
                        {
                            t.Rows.Add( buildSummary( Reason + n.Reason + " [" + Reason + or.NetworkConnections.Reason + "]" ) );
                        }
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) ) );
                    }
                }
                else
                {
                    if ( ( n.Number > 1 ) && ( or.NetworkConnections.Number == 1 ) )
                    {
                        t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) + " [" + NetworkConnectionNumber + or.NetworkConnections.Number.ToString( ) + "]" ) );
                        t.Rows.Add( buildSummary( Reason + n.Reason ) );
                    }
                    if ( ( n.Number == 1 ) && ( or.NetworkConnections.Number > 1 ) )
                    {
                        t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) + " [" + NetworkConnectionNumber + or.NetworkConnections.Number.ToString( ) + "]" ) );
                        t.Rows.Add( buildSummary( " [" + Reason + or.NetworkConnections.Reason + "]" ) );
                    }
                    if ( ( n.Number > 1 ) && ( or.NetworkConnections.Number > 1 ) )
                    {
                        t.Rows.Add( buildSummary( NetworkConnectionNumber + n.Number.ToString( ) + " [" + NetworkConnectionNumber + or.NetworkConnections.Number.ToString( ) + "]" ) );
                        if ( n.Reason.Equals( or.NetworkConnections.Reason, StringComparison.InvariantCultureIgnoreCase ) )
                        {
                            t.Rows.Add( buildSummary( Reason + n.Reason ) );
                        }
                        else
                        {
                            t.Rows.Add( buildSummary( Reason + n.Reason + " [" + Reason + or.NetworkConnections.Reason + "]" ) );
                        }
                    }
                }
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( DisasterRecovery dr, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Disaster Recovery"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                if ( dr.Requested == true )
                {
                    t.Rows.Add( buildSummary( DisasterRecoveryRequested + YES ) );
                    t.Rows.Add( buildSummary( DisasterRecoveryReplicationType + dr.ReplicationType ) );
                    if ( ( dr.Other != string.Empty ) && ( dr.Other != null ) )
                    {
                        t.Rows.Add( buildSummary( DisasterRecoveryReplicationTypeOther + dr.Other ) );
                    }
                }
                else
                {
                    t.Rows.Add( buildSummary( DisasterRecoveryRequested + NO ) );
                }
            }
            else
            {
                if ( dr.Requested == true )
                {
                    if ( dr.Requested == or.DisasterRecovery.Requested )
                    {
                        t.Rows.Add( buildSummary( DisasterRecoveryRequested + YES ) );
                        if ( dr.ReplicationType.Equals( or.DisasterRecovery.ReplicationType, StringComparison.InvariantCultureIgnoreCase ) )
                        {
                            t.Rows.Add( buildSummary( DisasterRecoveryReplicationType + dr.ReplicationType ) );
                        }
                        else
                        {
                            t.Rows.Add( buildSummary( DisasterRecoveryReplicationType + dr.ReplicationType + " [" + DisasterRecoveryReplicationType + or.DisasterRecovery.ReplicationType + "]" ) );
                        }
                        if ( ( dr.Other != string.Empty ) && ( dr.Other != null ) )
                        {
                            if ( ( or.DisasterRecovery.Other != string.Empty ) && ( or.DisasterRecovery.Other != null ) )
                            {
                                if ( dr.Other.Equals( or.DisasterRecovery.Other, StringComparison.InvariantCultureIgnoreCase ) )
                                {
                                    t.Rows.Add( buildSummary( DisasterRecoveryReplicationTypeOther + dr.Other ) );
                                }
                                else
                                {
                                    t.Rows.Add( buildSummary( DisasterRecoveryReplicationTypeOther + dr.Other + " [" + DisasterRecoveryReplicationTypeOther + or.DisasterRecovery.Other + "]" ) );
                                }
                            }
                        }
                        if ( ( dr.Other == string.Empty ) || ( dr.Other == null ) )
                        {
                            if ( ( or.DisasterRecovery.Other != string.Empty ) && ( or.DisasterRecovery.Other != null ) )
                            {
                                t.Rows.Add( buildSummary( "[" + DisasterRecoveryReplicationTypeOther + or.DisasterRecovery.Other + "]" ) );
                            }
                        }
                        if ( ( dr.Other != string.Empty ) && ( dr.Other != null ) )
                        {
                            if ( ( or.DisasterRecovery.Other == string.Empty ) || ( or.DisasterRecovery.Other == null ) )
                            {
                                t.Rows.Add( buildSummary( DisasterRecoveryReplicationTypeOther + dr.Other ) );
                            }
                        }
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( DisasterRecoveryRequested + YES + " [" + DisasterRecoveryRequested + NO + "]" ) );
                        t.Rows.Add( buildSummary( DisasterRecoveryReplicationType + dr.ReplicationType ) );
                        if ( ( dr.Other != string.Empty ) && ( dr.Other != null ) )
                        {
                            t.Rows.Add( buildSummary( DisasterRecoveryReplicationTypeOther + dr.Other ) );
                        }
                    }
                }
                else
                {
                    if ( dr.Requested == or.DisasterRecovery.Requested )
                    {
                        t.Rows.Add( buildSummary( DisasterRecoveryRequested + NO ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( DisasterRecoveryRequested + NO + " [" + DisasterRecoveryRequested + YES + "]" ) );
                        t.Rows.Add( buildSummary( " [" + DisasterRecoveryReplicationType + or.DisasterRecovery.ReplicationType + "]" ) );
                        if ( ( or.DisasterRecovery.Other != string.Empty ) && ( or.DisasterRecovery.Other != null ) )
                        {
                            t.Rows.Add( buildSummary( "[" + DisasterRecoveryReplicationTypeOther + or.DisasterRecovery.Other + "]" ) );
                        }
                    }
                }
            }
            p.Controls.Add( t );
            return ( panelsToHtmlString( p ) );
        }

        string setSummary( List<ServerRolesAndSubRoles> srasb, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Server Roles"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                foreach ( ServerRolesAndSubRoles s in srasb )
                {
                    if ( ( s.SubRoles != null ) && ( s.SubRoles.Count != 0 ) )
                    {
                        t.Rows.Add( buildSummary( s.ServerRole ) );
                        foreach ( string str in s.SubRoles )
                        {
                            t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + str ) );
                        }
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( s.ServerRole ) );
                    }
                }
            }
            else
            {
                bool CheckEquals = false;
                if ( ( srasb.Count != or.ServerRolesAndSubRoles.Count ) )
                {
                    CheckEquals = true;
                }
                if ( srasb.Count == or.ServerRolesAndSubRoles.Count )
                {
                    for ( int i = 0; i < srasb.Count; i++ )
                    {
                        if ( srasb[ i ].SubRoles.Count != or.ServerRolesAndSubRoles[ i ].SubRoles.Count )
                        {
                            CheckEquals = true;
                        }
                    }
                }
                if ( CheckEquals == true )
                {
                    foreach ( ServerRolesAndSubRoles s in srasb )
                    {
                        t.Rows.Add( buildSummary( s.ServerRole ) );
                        foreach ( string str in s.SubRoles )
                        {
                            t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + str ) );
                        }
                    }

                    foreach ( ServerRolesAndSubRoles s in or.ServerRolesAndSubRoles )
                    {
                        t.Rows.Add( buildSummary( "[" + s.ServerRole + "]" ) );
                        foreach ( string str in s.SubRoles )
                        {
                            t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "[" + str + "]" ) );
                        }
                    }
                }
                else
                {
                    foreach ( ServerRolesAndSubRoles s in srasb )
                    {
                        t.Rows.Add( buildSummary( s.ServerRole ) );
                        foreach ( string str in s.SubRoles )
                        {
                            t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + str ) );
                        }
                    }
                }
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        //string setSummary( ServerRoles sr, OriginalRequest or )
        //{
        //    Panel p = new Panel
        //    {
        //        GroupingText = "Server Roles"
        //    };
        //    Table t = new Table( );
        //    t.Width = new Unit( 100, UnitType.Percentage );
        //    if ( or.ServerBasics.ServerName == null )
        //    {
        //        foreach ( string s in sr.ServerRole )
        //        {
        //            t.Rows.Add( buildSummary( s ) );
        //            foreach ( ServerRolesAndSubRoles Sbr in sr.ServerSubRoles )
        //            {
        //                if ( s == Sbr.ServerRole )
        //                {
        //                    foreach ( string SbrString in Sbr.SubRoles )
        //                    {
        //                        t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + SbrString ) );
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    else
        //    {
        //        bool CheckEquals = false;
        //        if ( ( sr.ServerRole.Count != or.ServerRoles.ServerRole.Count ) )
        //        {
        //            CheckEquals = true;
        //        }
        //        if ( sr.ServerSubRoles.Count != or.ServerRoles.ServerSubRoles.Count )
        //        {
        //            CheckEquals = true;
        //        }
        //        if ( sr.ServerSubRoles.Count == or.ServerRoles.ServerSubRoles.Count )
        //        {
        //            for ( int i = 0; i < sr.ServerSubRoles.Count; i++ )
        //            {
        //                if ( sr.ServerSubRoles[ i ].SubRoles.Count != or.ServerRoles.ServerSubRoles[ i ].SubRoles.Count )
        //                {
        //                    CheckEquals = true;
        //                }
        //            }
        //        }
        //        if ( CheckEquals == true )
        //        {
        //            foreach ( string s in sr.ServerRole )
        //            {
        //                t.Rows.Add( buildSummary( s ) );
        //                foreach ( ServerRolesAndSubRoles Sbr in sr.ServerSubRoles )
        //                {
        //                    if ( s == Sbr.ServerRole )
        //                    {
        //                        foreach ( string SbrString in Sbr.SubRoles )
        //                        {
        //                            t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + SbrString ) );
        //                        }
        //                    }
        //                }
        //            }
        //            foreach ( string s in or.ServerRoles.ServerRole )
        //            {
        //                t.Rows.Add( buildSummary("[" + s + "]" ) );
        //                foreach ( ServerRolesAndSubRoles Sbr in or.ServerRoles.ServerSubRoles )
        //                {
        //                    if ( s == Sbr.ServerRole )
        //                    {
        //                        foreach ( string SbrString in Sbr.SubRoles )
        //                        {
        //                            t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "[" + SbrString + "]" ) );
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    if ( t.Rows.Count == 0 )
        //    {
        //        return ( string.Empty );
        //    }
        //    else
        //    {
        //        p.Controls.Add( t );
        //        return ( panelsToHtmlString( p ) );
        //    }
        //}
        string setSummary( List<Access> a, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Access"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                foreach ( Access ac in a )
                {
                    if ( ( ac.User != null ) && ( ac.Role != null ) )
                    {
                        if ( ( ac.User != string.Empty ) && ( ac.Role != string.Empty ) )
                        {
                            t.Rows.Add( buildSummary( ac.User + " : " + ac.Role ) );
                        }
                    }
                }
            }
            else
            {
                bool CheckEquals = false;
                if ( a.Count != or.Access.Count )
                {
                    CheckEquals = true;
                }
                if ( a.Count == or.Access.Count )
                {
                    for ( int i = 0; i < a.Count; i++ )
                    {
                        if ( ( a[ i ].User.Equals( or.Access[ i ].User, StringComparison.InvariantCultureIgnoreCase ) ) && ( a[ i ].Role.Equals( or.Access[ i ].Role, StringComparison.InvariantCultureIgnoreCase ) ) )
                        {
                        }
                        else
                        {
                            CheckEquals = true;
                        }
                    }
                }
                if ( CheckEquals == true )
                {
                    foreach ( Access ac in a )
                    {
                        if ( ( ac.User != null ) && ( ac.Role != null ) )
                        {
                            if ( ( ac.User != string.Empty ) && ( ac.Role != string.Empty ) )
                            {
                                t.Rows.Add( buildSummary( ac.User + " : " + ac.Role ) );
                            }
                        }
                    }

                    foreach ( Access ac in or.Access )
                    {
                        if ( ( ac.User != null ) && ( ac.Role != null ) )
                        {
                            if ( ( ac.User != string.Empty ) && ( ac.Role != string.Empty ) )
                            {
                                t.Rows.Add( buildSummary( "[" + ac.User + " : " + ac.Role + "]" ) );
                            }
                        }
                    }
                }
                else
                {
                    foreach ( Access ac in a )
                    {
                        if ( ( ac.User != null ) && ( ac.Role != null ) )
                        {
                            if ( ( ac.User != string.Empty ) && ( ac.Role != string.Empty ) )
                            {
                                t.Rows.Add( buildSummary( ac.User + " : " + ac.Role ) );
                            }
                        }
                    }
                }
            }
            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( Notes n, OriginalRequest or )
        {
            Panel p = new Panel
            {
                GroupingText = "Notes"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            if ( or.ServerBasics.ServerName == null )
            {
                if ( ( n.Note != null ) && ( n.Note != string.Empty ) )
                {
                    t.Rows.Add( buildSummary( Notes + n.Note ) );
                }
            }
            else
            {
                if ( ( n.Note != null ) && ( n.Note != string.Empty ) )
                {
                    if ( n.Note.Equals( or.Notes.Note, StringComparison.InvariantCultureIgnoreCase ) )
                    {
                        t.Rows.Add( buildSummary( Notes + n.Note ) );
                    }
                    else
                    {
                        t.Rows.Add( buildSummary( Notes + n.Note + " [" + Notes + or.Notes.Note + "]" ) );
                    }
                }
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( BackUp b )
        {
            Panel p = new Panel
            {
                GroupingText = "Back Up"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            if ( b.CompletedFlag != null )
            {
                if ( b.CompletedFlag == true )
                {
                    t.Rows.Add( buildSummary( isBackupCompleted + YES ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( isBackupCompleted + NO ) );
                }
            }

            if ( ( b.Policy != null ) && ( b.Policy != string.Empty ) )
            {
                t.Rows.Add( buildSummary( BackupPolicy + b.Policy ) );
            }
            if ( ( b.Agent != null ) && ( b.Agent != string.Empty ) )
            {
                t.Rows.Add( buildSummary( BackupAgents + b.Agent ) );
            }
            if ( ( b.RetentionTime != null ) && ( b.RetentionTime != string.Empty ) )
            {
                t.Rows.Add( buildSummary( BackupRetentionTime + b.RetentionTime ) );
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( AD ad )
        {
            Panel p = new Panel
            {
                GroupingText = "AD"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            if ( ad.CompletedFlag != null )
            {
                if ( ad.CompletedFlag == true )
                {
                    t.Rows.Add( buildSummary( isAdCompleted + YES ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( isAdCompleted + NO ) );
                }
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( AntiVirus av )
        {
            Panel p = new Panel
            {
                GroupingText = "Anti Virus"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            if ( av.CompletedFlag != null )
            {
                if ( av.CompletedFlag == true )
                {
                    t.Rows.Add( buildSummary( isAvCompleted + YES ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( isAvCompleted + NO ) );
                }
            }

            if ( ( av.Policy != string.Empty ) && ( av.Policy != null ) )
            {
                t.Rows.Add( buildSummary( AvPolicy + av.Policy ) );
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( MoniteringNetwork mn )
        {
            Panel p = new Panel
            {
                GroupingText = "Monitering"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            if ( mn.CompletedFlag != null )
            {
                if ( mn.CompletedFlag == true )
                {
                    t.Rows.Add( buildSummary( isMnCompleted + YES ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( isMnCompleted + NO ) );
                }
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( Patch pa )
        {
            Panel p = new Panel
            {
                GroupingText = "Patch"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            if ( pa.CompletedFlag != null )
            {
                if ( pa.CompletedFlag == true )
                {
                    t.Rows.Add( buildSummary( isPatchCompleted + YES ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( isPatchCompleted + NO ) );
                }
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setSummary( Build b )
        {
            Panel p = new Panel
            {
                GroupingText = "Build"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            if ( b.CompletedFlag != null )
            {
                if ( b.CompletedFlag == true )
                {
                    t.Rows.Add( buildSummary( isBuildCompleted + YES ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( isBuildCompleted + NO ) );
                }
            }

            foreach ( BuildUserInfo bui in b.BuildInfo )
            {
                t.Rows.Add( buildSummary( bui.CompletedTask + " completed by " + bui.CurrentLoggedInUser + " at " + bui.CurrentDateTime ) );
            }

            if ( t.Rows.Count == 0 )
            {
                return ( string.Empty );
            }
            else
            {
                p.Controls.Add( t );
                return ( panelsToHtmlString( p ) );
            }
        }

        string setTotalSummary( string totalSummary )
        {
            Panel p = new Panel
            {
                GroupingText = "Server Summary"
            };
            Label newLabel = new Label( );
            newLabel.Text = totalSummary;
            p.Controls.Add( newLabel );
            return ( panelsToHtmlString( p ) );
        }

        string tableclass( )
        {
            {
                string s = ( ( summaryRow % 2 ) == 0 ) ? CssClass.SummaryRowOdd : CssClass.SummaryRowEven;
                summaryRow++;
                return s;
            }
        }

        #endregion Methods
    }

    class CssClass
    {
        #region Fields

        public const string Data = "data";
        public const string Label = "label";
        public const string SummaryRowEven = "d1";
        public const string SummaryRowOdd = "d0";

        #endregion Fields
    }

    class TextAlign
    {
        #region Fields

        public const string Left = "left";
        public const string Right = "right";
        public const string summaryAdjustLeftPart = "summaryAdjustLeftPart";
        public const string summaryAdjustRightPart = "summaryAdjustRightPart";

        #endregion Fields
    }
}